package com.parking.carsystem.parkingchargesystem.fragment;

import android.support.v4.app.Fragment;

import java.util.HashMap;

/**
 * Created by Administrator on 2017/10/25 0025.
 */

public class FragmentFactory {
    public static final int DRAWCOLOR = 0;
    public static final int INPUTPLATE = 1;
    public static final int FAILURE = 2;
    public static HashMap<Integer, Fragment> fragmentHashMap = new HashMap<>();
    public static HashMap<Integer, Fragment> fragmentHashMap1 = new HashMap<>();
    public static HashMap<Integer, Fragment> fragmentHashMap2 = new HashMap<>();

    public static Fragment getFragmentInsance(int position) {
        Fragment fragment = fragmentHashMap.get(position);
        if (fragment == null) {
            switch (position) {
                case DRAWCOLOR:
                    fragment = new ChooseLisensePlateFragment();//绘制颜色
                    break;
                case INPUTPLATE:
                    fragment = new InputLisensePlateFragment();
                    break;
            }
            fragmentHashMap.put(position, fragment);
        }
        return fragment;
    }
    public static Fragment getCouponFragmentInsance(int position) {
        Fragment fragment = fragmentHashMap1.get(position);
        if (fragment == null) {
            switch (position) {
                case DRAWCOLOR:
                    fragment = new CouponNotUseFragment();//未使用
                    break;
                case INPUTPLATE:
                    fragment = new CouponAlreadyUsedFragment();//已使用
                    break;
                case FAILURE:
                    fragment = new CouponFailureFragment();//已失效
                    break;
            }
            fragmentHashMap1.put(position, fragment);
        }
        return fragment;
    }

    public static Fragment getCustumFragmentInsance(int position) {
        Fragment fragment = fragmentHashMap2.get(position);
        if (fragment == null) {
            switch (position) {
                case DRAWCOLOR:
                    fragment = new HomeFragment();//绘制颜色
                    break;
                case INPUTPLATE:
                    fragment = new UserFragment();
                    break;
            }
            fragmentHashMap2.put(position, fragment);
        }
        return fragment;
    }
}
